Link to PollyCommonR repo : pollycommonr
library(PollyCommonR)
raw_data <- read.csv("data/demo_raw_intensity.csv", stringsAsFactors = FALSE, check.names = FALSE)
head(raw_data)
metadata <- read.csv("data/demo_metadata.csv", stringsAsFactors = FALSE)
head(metadata)
raw_data$uniqueId <- paste0(raw_data$groupId, "_", raw_data$compound)
sample_raw_mat <- sample_intensity_matrix(raw_intensity_df = raw_data, metadata_df = metadata,rownames_col = "uniqueId")
sample_raw_mat <- sample_raw_mat + 1
head(sample_raw_mat)
cov_cal_df <- calculate_cohortwise_cov(raw_matrix = sample_raw_mat, metadata = metadata, cohort_col = "Cohort")
head(cov_cal_df)
p <- create_cohortwise_cov_boxplot(calculated_cov_df = cov_cal_df, interactive = FALSE)
p
p <- create_cohortwise_cov_barplot(calculated_cov_df = cov_cal_df,id_order = '1087_Std-L-Phenylalanine', id_col = 'id')
p
p <- create_boxplot_on_matrix(sample_raw_mat = sample_raw_mat, x_label = "Sample",y_label = "Raw Intensity",title_label = "Boxplot on Raw Data")
p
p <- create_densityplot_on_matrix(sample_raw_mat)
p
pca_compute <- compute_pca(sample_raw_mat = sample_raw_mat)
plot_proportion_of_variance(PCAObj_Summary = pca_compute)
p <- plot_pca(pca_compute, metadata = metadata, condition = 'Cohort', title_label = "PCA on Raw Data", interactive = FALSE)
p
p <- plot_pca3d(pca_compute, metadata = metadata, condition = 'Cohort', pc_x = 1, pc_y = 2, pc_z = 3, title_label = "PCA on Raw Data")
p
norm_agent <- t(sample_raw_mat["1087_Std-L-Phenylalanine",])
head(norm_agent)
norm_mat <- normalize_by_scaling_factor(sample_raw_mat, normalization_agent = norm_agent, scaling_factor_col = 1)
log2_norm_mat <- log2(norm_mat)
log2_norm_mat_shift <- max(abs(log2_norm_mat)) + log2_norm_mat
head(log2_norm_mat_shift)
p <- create_boxplot_on_matrix(log2_norm_mat_shift, x_label = "Sample",y_label = "Normalized Intensity",title_label = "Boxplot on Normalized Data")
p
p <- create_densityplot_on_matrix(log2_norm_mat_shift)
p
norm_pca_compute <- compute_pca(log2_norm_mat_shift)
plot_proportion_of_variance(PCAObj_Summary = norm_pca_compute)
p <- plot_pca(norm_pca_compute,metadata = metadata, condition = 'Cohort', title_label = "PCA on Normalized Data", interactive = FALSE)
p
p <- plot_pca3d(norm_pca_compute, metadata = metadata, condition = 'Cohort', pc_x = 1, pc_y = 2, pc_z = 3, title_label = "PCA on Normalized Data")
p
filtered_metadata <- filter_metadata_by_cohorts(metadata, condition = "Cohort", selected_cohorts = c("Cohort_2", "Cohort_5", "Cohort_3"))
filtered_log2_norm_mat_shift <- log2_norm_mat_shift[,filtered_metadata[,1]]
filtered_pca_compute <- compute_pca(filtered_log2_norm_mat_shift)
p <- plot_pca(filtered_pca_compute, metadata = metadata, condition = 'Cohort', title_label = "PCA on Normalized Data", interactive = FALSE)
p
p <- create_samplewise_barplot(log2_norm_mat_shift, metadata, id_name = "2_GMP", cohort_col = "Cohort",
x_label = "Sample", y_label = "Normalized Intensity", title_label = "GMP")
p
diff_exp <- diff_exp_limma(prot_norm_mat = log2_norm_mat_shift, metadata, cohort_condition = 'Cohort',
cohort_a = "Cohort_2", cohort_b = "Cohort_1",
p_val_correct_methods = "BH(FDR)", log_flag = FALSE)
p <- plot_volcano_from_limma(diff_exp_rdesc = diff_exp, log2fc_range = 0, p_val_cutoff = 0.05, interactive = FALSE)
p
log2_norm_mat_shift_anova <- one_way_anova_on_matrix(log2_norm_mat_shift, metadata_df = metadata, cohort_col = "Cohort")
head(log2_norm_mat_shift_anova)